package com.caishi.lkx.user.model;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler;
import com.zzw.common.entity.impl.BSDEntity;
import lombok.*;

import java.util.Map;

/**
 * @author by keray
 * date:2021/6/11 9:33 上午
 */
@EqualsAndHashCode(callSuper = true)
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@TableName(value = "cu_user_device", autoResultMap = true)
public class UserDeviceModel extends BSDEntity<UserDeviceModel> {

    @TableField(typeHandler = FastjsonTypeHandler.class)
    private Map<String, JSONObject> data;

//    public Map<DeviceType, UserDeviceState> getData() {
//        Map<DeviceType, UserDeviceState> _data = new HashMap<>();
//        for (String key : data.keySet()) {
//            _data.put(DeviceType.valueOf(key), BeanUtil.mapToBean(data.get(key), UserDeviceState.class, true, CopyOptions.create()));
//        }
//        return _data;
//    }
//
//    public void  setData(Map<DeviceType, UserDeviceState> data){
//        if(data != null){
//            this.data = new HashMap<>();
//            for (DeviceType key : data.keySet()) {
//                this.data.put(key.name(), JSONObject.parseObject(JSONObject.toJSONString(data.get(key))));
//            }
//        }
//
//    }

}
